<template>
  <div class="layui-row">
      <!-- 头部导航块 -->
      <top-lump>
        <div class="layui-btn-group">
            <button class="layui-btn" v-on:click="addStandard">增加</button>
            <button class="layui-btn">编辑</button>
            <button class="layui-btn">删除</button>
            <span class="layui-breadcrumb kgo-top-lump-breadcrumb" lay-separator="#">
                <a>#新增编程规范</a>
            </span>
        </div>
      </top-lump>
      <info-lump>
        <base-card title="新增编程规范">
            <table class="layui-table">
                <colgroup>
                    <col>
                    <col width="40%">
                    <col>
                    <col width="40%">
                </colgroup>
                <tbody>
                    <tr>
                        <td>规范名称</td>
                        <td class="kgo-input-td" colspan="3"><input  v-model="name" name="name" type="text" class="kgo-input-text"/></td>
                    </tr>
                    <tr>
                        <td>规范类别</td>
                        <td class="kgo-input-td"><alone-select catalogueCode="standard_type" v-model="setSelect" name="type"></alone-select></td>
                        <td>版本号</td>
                        <td class="kgo-input-td"><input v-model="version" name="version" type="text" class="kgo-input-text"/></td>
                    </tr>
                    <tr>
                        <td>关键字</td>
                        <td class="kgo-input-td" colspan="3"><input v-model="keyword" name="keyword" type="text" class="kgo-input-text"/></td>
                    </tr>
                    <tr>
                        <td>项目描述</td>
                        <td class="kgo-input-td" colspan="3"><wang-editor v-on:Html="getHtml" name="remark" ref="getEidt"></wang-editor></td>
                    </tr>
                </tbody>
            </table>

        </base-card>
      </info-lump>


  </div>
</template>

<script>

import Edit from 'wangeditor'
export default {
    components: {

    },
    data () {
        return {
            name:'',
            type:'',
            version:'',
            keyword:'',
            remark:''

        }
    },
    computed: {
        setSelect(){
          var selected = this.$store.state.aloneSelect;{
              if(selected["status"]){
                    console.log("状态 ：" + selected["status"]);
                    this.status = selected["status"];
              }if(selected["type"]){
                    console.log("类型 ：" + selected["type"]);
                    this.type = selected["type"];
              }
          }
        }
    },
   mounted(){
       layui.form.render('select');
   },
   methods:{
        getHtml:function(value){
            console.log("dddd : "+value);
            this.remark = value;
        },
        emptyEdit:function(){
           this.$refs.getEidt.emptyEdit();
           this.name=null;
           this.type=null;
           this.version = null;
           this.keyword = null;
           this.remark = null;
        },
      addStandard:function(){
            //触发获取文本域的方法
            this.$refs.getEidt.getHtml();
            var that = this;
            var standard_obj = {
                "name":this.name,
                "type":this.type,
                "projectId": this.$store.state.projectId,
                "version":this.version,
                "keyword":this.keyword,
                "remark":this.remark
            };
            if(standard_obj.name==null||standard_obj.name==""){
                layer.msg("规范名称不能为空！请检查");
                return;
            }
            if(standard_obj.version==null||standard_obj.version==""){
                layer.msg("规范版本号不能为空！请检查");
                return;
            }
            var $ = layui.$;
            var url = this.$store.state.RootURL + "/standard";
            $.post(url,standard_obj,function(result){
                layer.msg(result.msg);
                if(result.success){
                  that.emptyEdit();
                }
            },"json");
            
        },

   }
}
</script>

<style lang="scss">
.kgo-input-text{
    height: 35px;
    width: 100%;
    border-radius: 5px;
    border: 1px solid #e6e6e6;
}

</style>
